package com.valiscalc.util.statistics;

import cn.hutool.core.math.MathUtil;
import com.valiscalc.entity.SuperLotto;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author guozh
 * @Classname LottoStatistics
 * @Description TODO
 * @Date 2020/11/18 13:39
 * @Created by vallis
 */
public class LottoStatistics {
    
    
    /**
     * 判断该实票是否合法
     * 1.金额
     *
     * @param superLotto
     * @return
     */
    public  boolean isCorrect(SuperLotto superLotto){
    boolean one=false;
    boolean two=false;
        
        //      1.判断价格
        Long singlePrice = getSinglePrice(superLotto);
        System.out.println("该彩票价值"+singlePrice+"元");
        if (singlePrice<20000 &&singlePrice>0){
            one=true;
        }

    
    return one;
    
    }
    
    /**
     * 计算该实票的价格
     * @param
     * @return
     */
    public Long getSinglePrice(SuperLotto superLotto) {
        String frontNum[] = superLotto.getFrontNum().split(",");
        String endNum[] = superLotto.getEndNum().split(",");
        long fp = MathUtil.combinationCount(frontNum.length, 5);
        long ep = MathUtil.combinationCount(endNum.length, 2);
        return fp * ep * 2;
    }
    
    
    /**
     * 将复试彩票分解成单注的形式
     *
     * @param superLotto
     *
     * @return
     */
    public List<LottoTicket> decomposed(SuperLotto superLotto) {
        
        return CalcLotteryUtil.decomposed(superLotto);
    }
    
    /**
     * 将单注彩票分解成N个N+0
     *
     * @param superLotto
     *
     * @return
     */
    public static List<String[]> decomposedFront(SuperLotto superLotto, int n) {
        String[] checkNumber = CalcLotteryUtil.changeToArray(superLotto.getFrontNum());
        
        return MathUtil.combinationSelect(checkNumber, n);
    }
    
    /**
     * 将单注彩票分解成N个0+N
     *
     * @param superLotto
     *
     * @return
     */
    public static List<String[]> decomposedEnd(SuperLotto superLotto, int n) {
        String[] checkNumber = CalcLotteryUtil.changeToArray(superLotto.getEndNum());
        
        return MathUtil.combinationSelect(checkNumber, n);
    }
    
    
}
